package cn.fj.basic.service.impl;

import cn.fj.basic.mapper.BaseMapper;
import cn.fj.basic.query.BaseQuery;
import cn.fj.basic.service.IBaseService;
import cn.fj.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseServiceimpl<T> implements IBaseService<T> {

@Autowired
private BaseMapper<T> basemapper;


    @Override
    public List<T> findAll() {

        List<T> list = basemapper.loadAll();
        return list;
    }

    @Override
    public void delete(Long id) {
        basemapper.remove(id);
    }

    @Override
    public T findById(Long id) {

        return  basemapper.loadById(id);
    }

    @Override
    public PageList queryData(BaseQuery basequery) {
        Integer count = basemapper.count(basequery);
        System.out.println(count);
        //查询每页数据
        List<T> list = basemapper.queryData(basequery);
        PageList<T> PageList = new PageList<T>(count, list);
        return PageList;
    }

    @Override
    public void add(T t) {
        basemapper.save(t);

    }

    @Override
    public void update(T t) {
        basemapper.update(t);

    }
    @Override
    public void allDelete(List ids) {
        basemapper.allDelete(ids);

    }
}
